package logic

import (
	"baidu/baidurpc/baidurpc"
	"baidu/baidurpc/internal/svc"
	"baidu/modil/mysql"
	"context"

	"github.com/zeromicro/go-zero/core/logx"
)

type TypesLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TypesLogic {
	return &TypesLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *TypesLogic) Types(in *baidurpc.TypesRequest) (*baidurpc.TypesResponse, error) {
	// todo: add your logic here and delete this line
	types := mysql.Types{
		Type:   in.Type,
		TextId: in.TextId,
	}
	mysql.DB.Debug().Create(&types)
	return &baidurpc.TypesResponse{
		TypeId: int64(types.ID),
	}, nil
}
